package com.ThreadDemo;

/*
*
* 设置和获取线程优先级的方法
            public final int getPriority() 返回此线程的优先级
            public final void setPriority(int newpriority)更改线程优先级
* */

public class ThreadSleepDemo {
    public static void main(String[] args) {
        ThreadSleep tp1 = new ThreadSleep();
        ThreadSleep tp2 = new ThreadSleep();

//        tp1.setName("刘备");
//        tp2.setName("曹操");
//        tp3.setName("孙权");
//
//        tp1.start();
//        try {
//            tp1.join();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        tp2.start();
//        tp3.start();

        tp1.setName("关羽");
        tp2.setName("张飞");

        //设置主线程为刘备
        Thread.currentThread().setName("刘备");

        //设置守护线程
        tp1.setDaemon(true);
        tp2.setDaemon(true);

        tp1.start();
        tp2.start();

        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
        }

    }
}
